<?php
// phpinfo();
echo "connecting to data base...<br>";

//putenv("ORACLE_HOME=/usr/local/libexec/oracle/app/oracle/product/11.2.0/client_1");
$connection = oci_new_connect($username = 'yqiao', $password = 'chang526',
                          $connection_string = '//oracle.cise.ufl.edu/orcl');

if($connection)
    echo "Connected!<br>";

$statement = oci_parse($connection, 'SELECT * FROM ' . (isset($_REQUEST["table"])?$_REQUEST["table"]:"student"));
oci_execute($statement);
if($statement)
    echo "statement OK!<br>";

echo "<table border='1'>\n";
while ($row = oci_fetch_array($statement, OCI_ASSOC+OCI_RETURN_NULLS)) {
    echo "<tr>\n";
    foreach ($row as $item) {
        echo "    <td>" . ($item !== null ? htmlentities($item, ENT_QUOTES) : "&nbsp;") . "</td>\n";
    }
    echo "</tr>\n";
}
echo "</table>\n";


if($row)
    echo "row OK!<br>";
//
// VERY important to close Oracle Database Connections and free statements!
//
oci_free_statement($statement);
oci_close($connection);

?>
